using System.Collections.Generic;
using Roslyn.Compilers.CSharp;

namespace BITS.PreCompiler.CSharp.Syntax.Extensions
{
    /// <summary>
    /// Extension methods for method nodes.
    /// </summary>
    public static partial class MethodExtension
    {
        /// <summary>
        /// Updates the method body.
        /// </summary>
        /// <param name="methodNode">The method node.</param>
        /// <param name="statements">The statements.</param>
        /// <returns></returns>
        public static MethodDeclarationSyntax UpdateMethodBody(this MethodDeclarationSyntax methodNode, IEnumerable<SyntaxNode> statements)
        {
            return Roslyn.Compilers.CSharp.Syntax.MethodDeclaration(methodNode.Attributes, methodNode.Modifiers, methodNode.ReturnType,
                methodNode.ExplicitInterfaceSpecifier, methodNode.Identifier, methodNode.TypeParameterList,
                methodNode.ParameterList, methodNode.ConstraintClauses,
                Roslyn.Compilers.CSharp.Syntax.Block(methodNode.Body.OpenBraceToken, Roslyn.Compilers.CSharp.Syntax.List(statements), 
                methodNode.Body.CloseBraceToken), methodNode.SemicolonToken);
        }
    }
}